import request from '@/utils/request';
import { requestWrapper, randomDate } from '@/utils/mock';

// 获取概览数据
export function getOverviewData(params) {
  return requestWrapper(
    // 真实API请求
    () => request({
      url: '/dashboard/overview',
      method: 'get',
      params
    }),
    // 模拟数据
    {
      visitCount: 12580,
      userCount: 3250,
      messageCount: 158,
      orderCount: 2165,
      todayVisit: 356,
      todayUser: 85,
      todayMessage: 32,
      todayOrder: 128
    }
  );
}

// 获取趋势图数据
export function getTrendData(params) {
  const mockData = {
    xAxis: ["2023-01-01", "2023-01-02", "2023-01-03", "2023-01-04", "2023-01-05", "2023-01-06", "2023-01-07"],
    series: [150, 230, 224, 218, 135, 147, 260]
  };
  return requestWrapper(
    // 真实API请求
    () => request({
      url: '/dashboard/trend',
      method: 'get',
      params
    }),
    // 模拟数据
    mockData
  );
}

// 获取系统通知
export function getSystemNotices(params) {
  const mockData = [
    {
      id: 1,
      title: "系统维护通知",
      content: "系统将于2023-06-10 02:00-04:00进行升级维护",
      type: "warn",
      createTime: "2023-06-08 10:00:00"
    },
    {
      id: 2,
      title: "新功能上线通知",
      content: "系统新增数据导出功能，欢迎使用",
      type: "info",
      createTime: "2023-06-05 14:30:00"
    }
  ];
  return requestWrapper(
    // 真实API请求
    () => request({
      url: '/dashboard/notices',
      method: 'get',
      params
    }),
    // 模拟数据
    mockData
  );
}

// 获取待办任务
export function getTodoTasks() {
  const mockData = [
    {
      id: 1,
      title: "审批销售订单",
      status: "pending",
      priority: "high",
      createTime: "2023-06-08 10:00:00",
      deadline: "2023-06-09 18:00:00"
    },
    {
      id: 2,
      title: "更新用户手册",
      status: "processing",
      priority: "medium",
      createTime: "2023-06-05 14:30:00",
      deadline: "2023-06-12 18:00:00"
    }
  ];
  return requestWrapper(
    // 真实API请求
    () => request({
      url: '/dashboard/todos',
      method: 'get'
    }),
    // 模拟数据
    mockData
  );
} 